﻿using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace FastCloud.Base
{
    public class Result
    {
        public class ResultModel
        {
            [JsonProperty("code")]
            public int Code { set; get; }
            [JsonProperty("message")]
            public string Message { set; get; }
            [JsonProperty("data")]
            public object Data { get; set; }
        }

        public static JsonResult CommonResult(int ReponseCode, string ResponseMessage, object ReponseData = null)
        {
            ResultModel returnJson = new ResultModel()
            {
                Code = ReponseCode,
                Message = ResponseMessage,
                Data = ReponseData ?? string.Empty
            };
            return new JsonResult(returnJson);
        }

        public static JsonResult OK(object ReponseData = null)
        {
            return CommonResult(0, "success", ReponseData);
        }
        public static JsonResult Error(object ReponseData = null)
        {
            return CommonResult(-1, "error", ReponseData);
        }
    }
}
